
#include "lpf.h"

lpf_t lpf_voltage, lpf_coil_temp, lpf_board_temp, lpf_battery, lpf_speed;

void lpf_init(lpf_t *lpf, int32_t exec_freq, float const_time)
{
    float ts = 1.0f/exec_freq;
    lpf->a = const_time / (ts + const_time);
    lpf->ac = 1 - lpf->a;
}

float lpf_run(lpf_t *lpf, float input)
{
    lpf->out = lpf->ac * input + lpf->a * lpf->out;
    return lpf->out;
}